<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/cts/css/style.css" type="text/css"/>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/common.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/popdiv.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.bgiframe.js"></script>
  
     <script type="text/javascript">
          
           $(function(){
		       // 数据安典
	           var ctstype = '<s:property value="#request.ctstype"/>';
	           var ctsStatus = '<s:property value="#request.status"/>';
	           if(ctstype == 'data'){
		           var type = '<s:property value="#request.type"/>';
		           var typeDetail = '<s:property value="#request.typeDetail"/>';
		           
		           $("#xemployee"+type)[0].className = "selectBtn";
		           $("#employee"+typeDetail)[0].className = "selectBtn";
	           }
	           
	           $("#main"+ctstype)[0].className = 'mainselectBtn';
	           $("#status").find("option[id="+ctsStatus+"]").attr("selected" , "selected");
	           
	           $("#statusl1").find("option[id='<s:property value="#request.statusl1"/>']").attr("selected" , "selected");
	           $("#statusl2").find("option[id='<s:property value="#request.statusl2"/>']").attr("selected" , "selected");
	       });
       
		   // 数据字典
		   function showSingleData(id){
		      var type = '<s:property value="#request.type"/>';
		      var typeDetail = '<s:property value="#request.typeDetail"/>';
		      var ctsType = '<s:property value="#request.ctstype"/>';
		      
		      var url = "cts/findSingleCtsInfo.action?ctstype="+ctsType+"&type="+type+"&typeDetail="+typeDetail;
		      if(ctsType == 'data'){
		        url = "cts/findDataDicationary.action?ctstype="+ctsType+"&type="+type+"&typeDetail="+typeDetail;
		        $("#addCts").find("div[class='popdiv_handle']").text('添加数据字典');
		        if(id!=null && id!=''){
		           $("#addCts").find("div[class='popdiv_handle']").text('修改数据字典');
		        }
		      }else if(ctsType == 'item'){
		        $("#addCts").find("div[class='popdiv_handle']").text('添加委托项目');
		        if(id!=null && id!=''){
		           $("#addCts").find("div[class='popdiv_handle']").text('修改委托项目');
		        }
		      }
		      
		      url  += "&id="+id;
		      openPopDiv( 'addCts' , url ,  200);
		      $("#addOrShowData").css({"width":"300px"});
		      $("#addOrShowData").find("div[class='popdiv_content']").css({"height":"150px"});
		      if(ctsType == 'company'){
		        $("#addOrShowData").find("div[class='popdiv_content']").css({"height":"300px"});
		      }
		      
		      $("#addOrShowData").find("div[class='popdiv_handle']").text("添加");
		   } 
		   
		   // 数据字典
		   function delSingleData(id){
		      if(!confirm("您确要进行此操作吗？")){
		        return;
		      }
		       var url = "cts/delDataDicationary?id="+id;
		       $.post(url , "" , function(data){
		          if(data == 1){
		            alert("操用成功");
		            window.location.reload();
		          }else if(data == 2){
		            alert("此数据已使用");
		          }else{
		            alert("操作失败");
		          }
		       });
		   }
           
           // 数据字典    
	       function changeUrl(typeDetail){
	          var type= '<s:property value="#request.type"/>';
	          window.location.href = "${pageContext.request.contextPath}/cts/findDataDicationaryList?type="+type+"&typeDetail="+typeDetail+"&ctstype=data";
	       }
	       
	       // 数据字典
	       function changeUrlc11(type){
	          window.location.href = "${pageContext.request.contextPath}/cts/findDataDicationaryList?type="+type+"&typeDetail=1&ctstype=data";;
	       }
	       
           function orderData(){
		     var url = "cts/findDataDicationaryList.action?toOrder=true&type=<s:property value="#request.type"/>&typeDetail=<s:property value="#request.typeDetail"/>&ctstype=data";
		     // dataOrder
		     openPopDiv( 'dataOrder' , '' ,  50);
		     $("iframe[id='showDataOrder']").attr("src" , url);
		   }
		   
		   function closeDataOrderWin(){
		     //$("#dataOrder").hide();
		     //$("iframe[id='showDataOrder']").attr("src" , null);
		     window.location.reload();
		   }
		   
		   function changeModuel(url){
		      window.location.href = url;
		   }
		   
		   
		   // 委托项目
		   function delCstSingleInfo(id){
		      if(!confirm("您确要进行此操作吗？")){
		        return;
		      }
		       var ctstype = '<s:property value="#request.ctstype"/>';
		       var url = "cts/delCtsInfo.action?ctstype="+ctstype;
		       url  += "&id="+id;
		       $.post(url,"",function(data){
		          if(data == 1){
		            alert("操用成功");
		            window.location.reload();
		          }else if(data == 2){
		            alert("此项目已使用");
		          }else{
		            alert("操作失败");
		          }
		       })
		   }
		   
		   
		   function changeCpyStatue(){
		      var statusl1 = $("#statusl1").val();
		      var statusl2 = $("#statusl2").val();
		      var status   = $("#allDataFrom").find("input[id='status']");
		      
		      if(statusl1 == '' || statusl2 == ''){
		        $(status).val('');
		      }else if(statusl1 == '0'){
		        $(status).val(statusl2);
		      }else if(statusl1 == '1'){
		        $(status).val(statusl1);
		      }
		   }
		</script>
		
		<STYLE type="text/css">
			  #datacon table tr td{
			    height:30px;
			    border-bottom:1px dotted gray;
			  }
			  
			  .selectBtn{
			     border:none;
			     padding:5px 10px 5px 10px;
			     background-color:gray;
			     float:left;
			     color:#ffffff;
			     font-weight: bold;
			     font-size:10px;
			  }
			  
			  .noselectBtn{
			     border:none;
			     padding:5px 10px 5px 10px;
			     background-color:#ececec;
			     float:left;
			     font-size:10px;
			  }
			  
		  	  .mainselectBtn{
			     border:none;
			     padding:5px 10px 5px 10px;
			     background-color:gray;
			     color:#ffffff;
			     font-weight: bold;
			     margin-right:10px;
			     float:left;
			  }
			  
			  .mainnoselectBtn{
			     border:none;
			     padding:5px 10px 5px 10px;
			     /*background-color:#dddddd;*/
			     margin-right:10px;
			     float:left;
			  }
				  
	  </STYLE>
  </head>
  
  <body>
    <form action="findCtsInfo" id="allDataFrom" method="post">
	     <div align="center">
	       <div id="mainToolCon" style="width:850px;height:27px;">
	          <input class="mainnoselectBtn" type="button" id="mainuser" name="mainUser" value="用户" onclick="changeModuel('${pageContext.request.contextPath}/cts/findCtsInfo?ctstype=user')"/>
	          <input class="mainnoselectBtn" type="button" id="maincompany" name="mainCompany" value="公司"  onclick="changeModuel('${pageContext.request.contextPath}/cts/findCtsInfo?ctstype=company')"/>
	          <!-- 
	          <input class="mainnoselectBtn" type="button" id="mainitem" name="mainItem" value="委托项目"  onclick="changeModuel('${pageContext.request.contextPath}/cts/findCtsInfo?ctstype=item')"/>
	           -->
	          <input class="mainnoselectBtn" type="button" id="maindata" name="mainItem" value="数据字典"  onclick="changeModuel('${pageContext.request.contextPath}/cts/findDataDicationaryList?type=1&typeDetail=1&ctstype=data')"/>
	          <input class="mainnoselectBtn" type="button" id="mainExit" name="mainExit" value="退出"  onclick="changeModuel('${pageContext.request.contextPath}/cts/logout')" style="float:right;"/>
	       </div>
	       
	       <div id="datacon" style="width:850px;border:1px solid gray;background-color:#ececec;margin-top:20px;">
	         <input type="hidden" id="ctstype" name="ctstype" value="<s:property value="#request.ctstype"/>"/>
	         <input type="hidden" id="createTime" name="createTime" value="<s:property value="#request.createTime"/>"/>
	         <input type="hidden" id="type" name="type" value="<s:property value="#request.type"/>"/>
	         <input type="hidden" id="typeDetail" name="typeDetail" value="<s:property value="#request.typeDetail"/>"/>
	         
	         <div align="right">
	              <s:if test="#request.ctstype == 'user'">用户名:</s:if>
		          <s:elseif test="#request.ctstype == 'company'">公司名:</s:elseif> 
		          <s:elseif test="#request.ctstype == 'item'">委托项目:</s:elseif> 
		          <s:elseif test="#request.ctstype == 'data'">数据字典:</s:elseif>     
		          <input id="workKey" type="text" name="workKey" value="<s:property value="#request.workKey"/>"/>&nbsp;&nbsp;
		           <!-- 
			              是否启用
			           <s:if test="#request.ctstype == 'company'">
			              <select id="status" name="status">
				              <option id="" value="">全部</option>
				              <option id="0" value="0">启用</option>
				              <option id="2" value="2">禁用</option>
				           </select>
			           </s:if>
		            -->   
		              状态
		           <s:if test="#request.ctstype == 'company'">
		           <!-- 
		              <select id="status" name="status">
			              <option id="" value="">全部</option>
			              <option id="0" value="0">未审核</option>
			              <option id="1" value="1">已审核</option>
			              <option id="2" value="2">禁用</option>
			           </select>
		            -->
		              <select id="statusl1" name="statusl1">
			              <option id="" value="">全部</option>
			              <option id="0" value="0">启用</option>
			              <option id="1" value="1">禁用</option>
			           </select>
			             审核状态
			           <select id="statusl2" name="statusl2">
			              <option id="" value="">全部</option>
			              <option id="0" value="0">未审核</option>
			              <option id="1" value="1">已审核</option>
			           </select>
			           <input type="hidden" id="status" name="status" value=""/>
		           </s:if>
		           
		           <s:elseif test="#request.ctstype == 'user'">
			           <select id="status" name="status">
			              <option id="" value="">全部</option>
			              <option id="0" value="0">正常</option>
			              <option id="1" value="1">禁用</option>
			              <option id="2" value="2">临时</option>
			           </select>
		           </s:elseif>
		           <s:else>
		               <select id="status" name="status">
			              <option id="" value="">全部</option>
			              <option id="0" value="0">正常</option>
			              <option id="1" value="1">禁用</option>
			           </select>
		           </s:else>
		           <input id="search" name="search" type="button" value="查询" onclick="getParam(1)"/>
		           
		           <s:if test="#request.ctstype == 'company'">
		              <input id="addComapny" name="addComapnay" type="button" value="添加公司" onclick="showSingleData()"/>
		           </s:if>
		           
		           <!-- 
		           <s:if test="#request.ctstype == 'data'">
		                <input id="search" name="search" type="button" value="查询" onclick="getParam(1)"/>
		           </s:if>
		           <s:else>
			           <input id="search" name="search" type="button" value="查询" onclick="getParam()"/>
		           </s:else>
		            -->
	         </div>
	         
	         <s:if test="#request.ctstype == 'data' ">
	              <table  style="font-size:12px;width:800px;margin-top:20px;margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0">
		          <tr>
		            <td>
		                  数据字典 >> <s:if test="#request.type == 1">FCL</s:if>
		              <s:elseif test="#request.type == 2">LCL</s:elseif>
		              <s:elseif test="#request.type == 3">AIR</s:elseif>
			          <s:elseif test="#request.type == 4">EXPRESS</s:elseif>
			          <s:elseif test="#request.type == 5">TRUCKING</s:elseif>
			          <s:elseif test="#request.type == 6">OTHERS</s:elseif>
		            </td>
		            <td colspan="2" align="right">
		               <a href="javascript:orderData()">
		                   <img src="${pageContext.request.contextPath}/cts/images/arrow_d.png" style="border:none;width:20px;height:20px;" hspace="4"/>排序
		               </a>
		                &nbsp;|&nbsp;
		                
		               <a href="javascript:showSingleData('')">
			               <img src="${pageContext.request.contextPath}/cts/images/add_1.png" style="border:none;width:20px;height:20px;" hspace="4"/>添加
			               <s:if test="#request.typeDetail == 1">货物类型</s:if>
			               <s:elseif test="#request.typeDetail == 2">交接方式</s:elseif>
			               <s:elseif test="#request.typeDetail == 3">运费支付方式</s:elseif>
			               <s:elseif test="#request.typeDetail == 4">放货方式</s:elseif>
			               <s:elseif test="#request.typeDetail == 5">包装类型</s:elseif>
			               <s:elseif test="#request.typeDetail == 6">接驳工具</s:elseif>
			               <s:elseif test="#request.typeDetail == 7">承运人</s:elseif>
		               </a>
		            </td>
		          </tr>
		          <tr>
		            <td colspan="3">
		              <input class="noselectBtn" type="button" id="xemployee1" name="n_xemployee1" onclick="changeUrlc11(1)" value="FCL"/>
		              <input class="noselectBtn" type="button" id="xemployee2" name="n_xemployee2" onclick="changeUrlc11(2)" value="LCL"/>
		              <input class="noselectBtn" type="button" id="xemployee3" name="n_xemployee3" onclick="changeUrlc11(3)" value="AIR"/>
		              <input class="noselectBtn" type="button" id="xemployee4" name="n_xemployee4" onclick="changeUrlc11(4)" value="EXPRESS"/>
		              <input class="noselectBtn" type="button" id="xemployee5" name="n_xemployee5" onclick="changeUrlc11(5)" value="TRUCKING"/>
		              <input class="noselectBtn" type="button" id="xemployee6" name="n_xemployee6" onclick="changeUrlc11(6)" value="OTHERS"/>
		            </td>
		          </tr>
		          <tr>
		            <td colspan="3">
		              <input class="noselectBtn" type="button" id="employee1" name="n_employee1" onclick="changeUrl(1)" value="货物类型"/>
		              <input class="noselectBtn" type="button" id="employee2" name="n_employee2" onclick="changeUrl(2)" value="交接方式"/>
		              <input class="noselectBtn" type="button" id="employee3" name="n_employee3" onclick="changeUrl(3)" value="运费支付方式"/>
		              <input class="noselectBtn" type="button" id="employee4" name="n_employee4" onclick="changeUrl(4)" value="放货方式"/>
		              <input class="noselectBtn" type="button" id="employee5" name="n_employee5" onclick="changeUrl(5)" value="包装类型"/>
		              <input class="noselectBtn" type="button" id="employee6" name="n_employee6" onclick="changeUrl(6)" value="接驳工具"/>
		              <input class="noselectBtn" type="button" id="employee7" name="n_employee7" onclick="changeUrl(7)" value="承运人"/>
		            </td>
		          </tr>
		          <tr>
		            <td style="border-bottom: 1px solid gray;padding-top:20px;width:40%;text-align:left;">名称</td>
		            <td style="border-bottom: 1px solid gray;padding-top:20px;width:30%;text-align:center;">是否可用</td>
		            <td style="border-bottom: 1px solid gray;padding-top:20px;text-align:right;width:30%;">操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		          </tr>
		          <s:iterator value="#request.list">
		             <tr>
			            <td style="text-align:left;"><s:property value="name"/>&nbsp;</td>
			            <td style="text-align: center;">
			               <s:if test="status == 0">正常</s:if>
			               <s:else>禁用</s:else>
			            </td>
		               <td width="35%" style="text-align:right;">
	                     <a href="javascript:showSingleData('<s:property value="id"/>')">修改</a> | <a href="javascript:delSingleData('<s:property value="id"/>')">删除</a>
	                    </td>
			         </tr>
		          </s:iterator>
		        </table>
	         </s:if>
	         <s:elseif test="#request.ctstype == 'item'">
	            <table style="font-size:12px;width:800px;margin-top:20px;margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0">
	              <tr>
	                 <td style="border:none;">&gt;&gt;添加委托项目</td>
		             <td colspan="4" align="right" style="border:none;">
		                <a href="javascript:showSingleData('')">
		                     <img src="${pageContext.request.contextPath}/cts/images/add_1.png" style="border:none;width:20px;height:20px;" hspace="4"/>添加委托项目
		                </a>
		             </td>
		          </tr>
		          <tr>
		            <td style="border-bottom: 1px solid gray;">名称(zh)</td>
		            <td style="border-bottom: 1px solid gray;">名称(en)</td>
		            <td style="border-bottom: 1px solid gray;">项目类型</td>
		            <td style="border-bottom: 1px solid gray;">状态</td>
		            <td style="border-bottom: 1px solid gray;text-align: right;">操作</td>
		          </tr>
		          <s:iterator value="#request.list">
		             <tr>
			            <td><s:property value="name_zh"/>&nbsp;</td>
			            <td><s:property value="name_en"/>&nbsp;</td>
			            <td>
			               <s:if test="type == 1">整箱海运</s:if>
			               <s:elseif test="type == 2">拼箱海运</s:elseif>
			               <s:elseif test="type == 3">空运</s:elseif>
			               <s:elseif test="type == 4">快递</s:elseif>
			               <s:elseif test="type == 5">卡车运输</s:elseif>
			               <s:elseif test="type == 5">卡车运输</s:elseif>
			               <s:elseif test="type == 6">货物加工</s:elseif>
			               <s:elseif test="type == 7">文件处理</s:elseif>
			               <s:elseif test="type == 8">短途运输</s:elseif>
			               &nbsp;
			            </td>
			            <td>
			               <s:if test="status == 0">正常</s:if>
			               <s:else>禁用</s:else>
			            </td>
			            <td  width="30%" style="text-align: right;">
			                <a href="javascript:showSingleData('<s:property value="id"/>')">修改</a> | <a href="javascript:delCstSingleInfo('<s:property value="id"/>')">删除</a>
			            </td>
			          </tr>
		          </s:iterator>
		        </table>
	         </s:elseif>
	         <s:elseif test="#request.ctstype == 'user'">
	               <table style="font-size:12px;width:800px;margin-top:20px;margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0">
			          <tr>
			            <td style="border-bottom: 1px solid gray;width:30%;">用户名</td>
			            <td style="border-bottom: 1px solid gray;width:30%;">用户状态</td>
			            <td style="border-bottom: 1px solid gray;width:30%;">创建日期</td>
			            <td style="border-bottom: 1px solid gray;text-align: right;width:10%;">操作</td>
			          </tr>
			          <s:iterator var="ps" value="#request.list" status="sta">
			             <tr>
				            <td><s:property value="userName"/>&nbsp;</td>
				            <td>
				               <s:if test="status == 0">正常</s:if>
				               <s:elseif test="status == 1">禁用</s:elseif>
				               <s:elseif test="status == 2">临时</s:elseif>
				            </td>
				            <td>
				               <s:date name="createTime" format="yyyy-MM-dd"/>
				            </td>
				            <td  width="30%" style="text-align: right;">
				                <a href="javascript:showSingleData('<s:property value="id"/>')">修改</a> | <a href="javascript:delCstSingleInfo('<s:property value="id"/>')">删除</a>
				            </td>
				          </tr>
			          </s:iterator>
			        </table>
	         </s:elseif>
	         <s:elseif test="#request.ctstype == 'company'">
	               <table style="font-size:12px;width:800px;margin-top:20px;margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0">
			          <tr>
			            <td style="border-bottom: 1px solid gray;">公司名称</td>
			            <td style="border-bottom: 1px solid gray;">公司前缀</td>
			            <td style="border-bottom: 1px solid gray;">公司管理员</td>
			            <td style="border-bottom: 1px solid gray;">启用状态</td>
			            <td style="border-bottom: 1px solid gray;">审核状态</td>
			            <td style="border-bottom: 1px solid gray;text-align: right;">操作</td>
			          </tr>
			          <s:iterator value="#request.list">
			             <tr>
				            <td><s:property value="name"/>&nbsp;</td>
				            <td><s:property value="prefix"/>&nbsp;</td>
				            <td><s:property value="user.userName"/>&nbsp;</td>
				            <td>
				               <s:if test="status == 0 || status == 1">启用</s:if>
				               <s:elseif test="status == 2">禁用</s:elseif>
				            </td>
				            <td >
				               <s:if test="status == 0">未审核</s:if>
				               <s:elseif test="status == 1">已审核</s:elseif>
				               <s:elseif test="status == 2">未审核</s:elseif>
				            </td>
				            <td  width="30%" style="text-align: right;">
				                <a href="javascript:showSingleData('<s:property value="id"/>')">修改</a> | <a href="javascript:delCstSingleInfo('<s:property value="id"/>')">删除</a>
				            </td>
				          </tr>
			          </s:iterator>
			        </table>
	         </s:elseif>
	         
			 <div style="width:99%;margin-left:20px;" align="center">
		         <jsp:include page="pageForm.jsp"></jsp:include>
				 <input type="hidden" id="urlforward"  value="" />
				 <div id="pagination" valign="middle" class="pagination" ></div>
			 </div>
	       </div>
	     </div>
     </form>
     
     <div id="addCts" name="n_addEmployee" class="popdiv_inner" style="width:300px;">
		<div class="popdiv_inner_outter"></div>
		<div class="popdiv_close"></div>
		<div class="popdiv_handle" title="鼠标左键按住可拖动">信息</div>
		<div class="popdiv_content" style="height:200px;text-align: center;">top:200</div>
	 </div>
	 
	 <div id="dataOrder" name="dataOrder" class="popdiv_inner" style="width:800px;">
		<div class="popdiv_inner_outter"></div>
		<div class="popdiv_close"></div>
		<div class="popdiv_handle" title="鼠标左键按住可拖动">数据字典排序</div>
		<div class="popdiv_content" style="height:600px;text-align: center;">
		  <iframe id="showDataOrder" scrolling="auto" style="width:775px;height:600px;" frameborder="0"></iframe>
		</div>
	 </div>
	 
	 <div id="uploadImage" name="n_uploadImage" class="popdiv_inner" style="width:340px;">
			<div class="popdiv_inner_outter"></div>
			<div class="popdiv_close"></div>
			<div class="popdiv_handle" title="鼠标左键按住可拖动">公司/个人头像</div>
		  <div class="popdiv_content" style="height:420px;">top:200</div>
     </div>
  </body>
</html>


<script type="text/javascript">
	function getParam(istype) {
	    $("#pageSize").val( $("#pageSize").val());
	    var pageNumberS = $("#pageNumber").val();
	    if(parseInt(pageNumberS) <= 0 || istype == 1){
	    	pageNumberS = '1';
	    }
	    $("#pageNumber").val(pageNumberS);
	    
	    var ctstype = '<s:property value="#request.ctstype"/>';
	    var url = "findCtsInfo";
        if(ctstype == 'data'){
          url = "findDataDicationaryList";
        }
        
        if(ctstype == 'company'){
          changeCpyStatue();
        }
        
	    var form = document.getElementById("allDataFrom");
        form.action = url;
        form.submit();
	}		    
		   
	paginationCommon(1);
</script>